﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CuaHangMayTinh.BusinessEntities;

namespace CuaHangMayTinh.PresentationLayer
{
    /// <summary>
    /// form hiển thị giao diện chính
    /// </summary>
    public partial class FormGiaoDienChinh : Form
    { 
        /// <summary>
        /// form khởi tạo
        /// </summary>
        public FormGiaoDienChinh()
        {
            InitializeComponent();
        }

        /// <summary>
        /// bặt sự kiện load form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormGiaoDienChinh_Load(object sender, EventArgs e)
        {
            DisableControlForm();
        }

        /// <summary>
        /// khóa các btn không được phép
        /// </summary>
        private void DisableControlForm()
        {
            var form = (FormChinh)this.MdiParent;
            btn_saoluugiulieu.Enabled = form.btn_Backup.Enabled;
            btn_phuchoidulieu.Enabled = form.btn_Restore.Enabled;
            btn_nhatkylog.Enabled = form.btn_Log.Enabled;
            btn_quanlyuser.Enabled = form.btn_QLUser.Enabled;
            btn_phanquyen.Enabled = form.btn_hethong_PhanQuyen.Enabled;
            btn_khachhang.Enabled = form.btn_KhachHang.Enabled;
            btn_nhacungcap.Enabled = form.btn_NhaCungCap.Enabled;
            btn_donvitinh.Enabled = form.btn_DonViTinh.Enabled;
            btn_loaimathang.Enabled = form.btn_LoaiMatHang.Enabled;
            btn_modelmathang.Enabled = form.btn_ModelMatHang.Enabled;
            btn_mathang.Enabled = form.btn_MatHang.Enabled;
            btn_bophan.Enabled = form.btn_BoPhan.Enabled;
            btn_nhanvien.Enabled = form.btn_NhanVien.Enabled;
            btn_nhaphang.Enabled = form.btn_NhapHang.Enabled;
            btn_banhang.Enabled = form.btn_BanHang.Enabled;
            btn_trahang.Enabled = form.btn_XK_TH.Enabled;
            btn_hoadonbanhang.Enabled = form.buttonItem_hdbanhang.Enabled;
            btn_hoadonbaohanhsuachua.Enabled = form.buttonItem_hdbaohanhsuachua.Enabled;
            btn_hoadonnhaphang.Enabled = form.buttonItem_hdnhaphang.Enabled;
            btn_hoadontrahang.Enabled = form.buttonItem_hdtrahang.Enabled;
            btn_baohanh.Enabled = form.btn_BH_SC.Enabled;
            btn_thongke.Enabled = form.btn_doanhthu.Enabled;
            btn_mhbanchay.Enabled = form.btn_mhbanchay.Enabled;
            btn_thongtin.Enabled = form.btn_thongtincuahang.Enabled;
        }

        /// <summary>
        /// các sự kiên được gọi lại trên form chính
        /// </summary>
        #region sự kiện nút
        private void btn_saoluugiulieu_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_HeThong;
            form.btn_Backup_Click(form,null);
        }

        private void btn_phuchoidulieu_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_HeThong;
            form.btn_Restore_Click(form, null);
        }

        private void btn_nhatkylog_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_HeThong;
            form.btn_Log_Click(form, null);
        }

        private void button_quanlyuser_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_HeThong;
            form.btn_QLUser_Click(form, null);
        }

        private void button_phanquyen_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_HeThong;
            form.btn_hethong_PhanQuyen_Click(form, null);
        }

        private void btn_nhanvien_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_DanhMuc;
            form.btn_NhanVien_Click(form, null);
        }

        private void btn_nhaphang_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_NghiepVu;
            form.btn_NhapHang_Click(form, null);
        }

        private void btn_bophan_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_DanhMuc;
            form.btn_BoPhan_Click(form, null);
        }

        private void btn_trahang_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_NghiepVu;
            form.btn_XK_TH_Click(form, null);
        }

        private void btn_loaimathang_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_DanhMuc;
            form.btn_LoaiMatHang_Click(form, null);
        }

        private void btn_mathang_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_DanhMuc;
            form.btn_MatHang_Click(form, null);
        }

        private void btn_donvitinh_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_DanhMuc;
            form.btn_DonViTinh_Click(form, null);
        }

        private void btn_modelmathang_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_DanhMuc;
            form.btn_ModelMatHang_Click(form, null);
        }

        private void btn_khachhang_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_DanhMuc;
            form.btn_KhachHang_Click(form, null);
        }

        private void btn_banhang_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_NghiepVu;
            form.btn_BanHang_Click(form, null);
        }

        private void btn_hoadonbanhang_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_BCTK;
            form.buttonItem_hdbanhang_Click(form, null);
        }

        private void btn_nhacungcap_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_DanhMuc;
            form.btn_NhaCungCap_Click(form, null);
        }

        private void btn_baohanh_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_NghiepVu;
            form.btn_BH_SC_Click(form, null);
        }

        private void btn_hoadonbaohanhsuachua_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_BCTK;
            form.buttonItem_hdbaohanhsuachua_Click(form, null);
        }

        private void btn_hoadonnhaphang_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_BCTK;
            form.buttonItem_hdnhaphang_Click(form, null);
        }

        private void btn_thongke_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_BCTK;
            form.btn_doanhthu_Click(form,null);
        }

        private void btn_hoadontrahang_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_BCTK;
            form.buttonItem_hdtrahang_Click(form, null);
        }

        private void btn_mathang_MouseEnter(object sender, EventArgs e)
        {
            linenh1.Visible = true;
            linenh2.Visible = true;
            linebh1.Visible = true;
            lineth1.Visible = true;
            lineth2.Visible = true;
            lineth3.Visible = true;
            lineth4.Visible = true;
            linesc1.Visible = true;
            linesc2.Visible = true;
            linesc3.Visible = true;
        }

        private void btn_mathang_MouseLeave(object sender, EventArgs e)
        {
            linenh1.Visible = false;
            linenh2.Visible = false;
            linebh1.Visible = false;
            lineth1.Visible = false;
            lineth2.Visible = false;
            lineth3.Visible = false;
            lineth4.Visible = false;
            linesc1.Visible = false;
            linesc2.Visible = false;
            linesc3.Visible = false;

            linenh1.BringToFront();
            linenh2.BringToFront();
            linebh1.BringToFront();
            lineth1.BringToFront();
            lineth2.BringToFront();
            lineth3.BringToFront();
            lineth4.BringToFront();
            linesc1.BringToFront();
            linesc2.BringToFront();
            linesc3.BringToFront();
        }

        private void btn_nhaphang_MouseEnter(object sender, EventArgs e)
        {
            for (int i = 1; i <= 10; i++)
            {
                this.Controls["linenh"+i].Visible = true;
            }
        }

        private void btn_nhaphang_MouseLeave(object sender, EventArgs e)
        {
            for (int i = 1; i <= 10; i++)
            {
                this.Controls["linenh" + i].Visible = false;
                this.Controls["linenh" + i].BringToFront();
            }
        }

        private void btn_banhang_MouseEnter(object sender, EventArgs e)
        {
            for (int i = 1; i <= 7; i++)
            {
                this.Controls["linebh" + i].Visible = true;
            }
        }

        private void btn_banhang_MouseLeave(object sender, EventArgs e)
        {
            for (int i = 1; i <= 7; i++)
            {
                this.Controls["linebh" + i].Visible = false;
                this.Controls["linebh" + i].BringToFront();
            }
        }

        private void btn_trahang_MouseEnter(object sender, EventArgs e)
        {
            for (int i = 1; i <= 10; i++)
            {
                this.Controls["lineth" + i].Visible = true;
            }
        }

        private void btn_trahang_MouseLeave(object sender, EventArgs e)
        {
            for (int i = 1; i <= 10; i++)
            {
                this.Controls["lineth" + i].Visible = false;
                this.Controls["lineth" + i].BringToFront();
            }
        }

        private void btn_baohanh_MouseEnter(object sender, EventArgs e)
        {
            for (int i = 1; i <=8 ; i++)
            {
                this.Controls["linesc" + i].Visible = true;
            }
        }

        private void btn_baohanh_MouseLeave(object sender, EventArgs e)
        {
            for (int i = 1; i <= 8; i++)
            {
                this.Controls["linesc" + i].Visible = false;
                this.Controls["linesc" + i].BringToFront();
            }
        }

        private void btn_dangxuat_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.btn_DangXuat_Click(form,null);
        }

        private void btn_doimatkhau_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.btn_DoiPass_Click(form,null);
        }

        private void btn_trogiup_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_TroGiup;
            form.btn_TroGiup_Click(form,null);
        }

        private void btn_thongtin_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_TroGiup;
            form.buttonItem_thongtin_Click(form, null);
        }
        private void btn_mhbanchay_Click(object sender, EventArgs e)
        {
            var form = (FormChinh)this.MdiParent;
            form.ribbonControl_hethong.SelectedRibbonTabItem = form.ribTab_BCTK;
            form.btn_mhbanchay_Click(form, null);
        }

#endregion

        

        


    }
}
